Today, almost every galaxy spheroid contains a massive black hole: a remnant of, and testament to, a period in its evolution when it contained an active galactic nucleus (AGN). However, the sequence and timescales of the formation of the black hole and surrounding spheroid of stars are completely unknown, leaving a large gap in our knowledge of how the Universe attained its present appearance. Here we present submillimeter observations of matched samples of X-ray absorbed and unabsorbed AGN which have luminosities and redshifts characteristic of the sources responsible for most of the mass in present day black holes. Strong submillimeter emission, an isotropic signature of copious star formation, is found only in the X-ray absorbed sample, ruling out orientation effects as the cause of the absorption. The space density and luminosity range of the X-ray absorbed AGN indicate that they are undergoing the transition between a hidden growth phase and an unabsorbed AGN phase, and implies that the X-ray absorbed period in the AGN's evolution coincides with the formation of the galaxy spheroid.